﻿using UnityEngine;
using System.Collections;
using RichLabelSpace;
using System.Diagnostics;
using System.Collections.Generic;


public class test_rich : MonoBehaviour 
{
    public GameObject mnt_go;
    private string rich_txt = "";

    private string path = "";

    void Awake()
    {
        path = System.IO.Path.Combine(Application.dataPath, "Scripts/RichLabelComponent/Editor/rich_lab.txt");
        UnityEngine.Debug.Log(path);
    }

    void OnGUI()
    {
        if(GUILayout.Button("TestRich"))
        {
            rich_txt = System.IO.File.ReadAllText(path);
            RichLabelMgr.CreateNewRichLab(rich_txt, mnt_go.transform, new Vector2(700, 200), NGUIText.Alignment.Left, (string id) =>
            {
               UnityEngine.Debug.Log("richevent  " + id);
            });
        }
    }
}

public static class Test
{
    private static Dictionary<string, Stopwatch> sample_dict = new Dictionary<string, Stopwatch>();

    public static void BeginSample(string key)
    {
        Stopwatch stw = new Stopwatch();
        stw.Start();
        sample_dict.Add(key, stw);
    }

    public static void EndSample(string key)
    {
        var stw = sample_dict[key];
        stw.Stop();
        var time = stw.ElapsedMilliseconds;
        sample_dict.Remove(key);

        UnityEngine.Debug.Log(key + "  elapsed: " + time);
    }
}
